package util;

public class ArrayUtils extends org.apache.commons.lang.ArrayUtils {
    
    public static byte[] add(byte[] array1, byte[] array2) {
        return ArrayUtils.add(array1, array2, null == array2 ? 0 : array2.length);
    }
    
    public static byte[] add(byte[] array1, byte[] array2, int length) {
        if (null == array1 && null == array2) {
            return null;
        } else if (null == array1 && null != array2) {
            return (byte[]) array2.clone();
        } else if (null != array1 && null == array2) {
            return (byte[]) array1.clone();
        }
        
        byte[] joinedArray = new byte[array1.length + length];
        System.arraycopy(array1, 0, joinedArray, 0, array2.length);
        System.arraycopy(array1, 0, joinedArray, array2.length, length);
        return joinedArray;
    }

    public static char[] add(char[] array1, char[] array2) {
        return ArrayUtils.add(array1, array2, null == array2 ? 0 : array2.length);
    }
    
    public static char[] add(char[] array1, char[] array2, int length) {
        if (null == array1 && null == array2) {
            return null;
        } else if (null == array1 && null != array2) {
            return (char[]) array2.clone();
        } else if (null != array1 && null == array2) {
            return (char[]) array1.clone();
        }
        
        char[] joinedArray = new char[array1.length + length];
        System.arraycopy(array1, 0, joinedArray, 0, array2.length);
        System.arraycopy(array1, 0, joinedArray, array2.length, length);
        return joinedArray;
    }
    
    public static void main(String[] args) {
        
    }
}
